<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('员工管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>员工编号：</label>
                                <input type="text" name="employeeId"/>
                            </li>
                            <li>
                                <label>员工姓名：</label>
                                <input type="text" name="employeeName"/>
                            </li>
<!--                            <li>-->
<!--                                <label>员工性别：</label>-->
<!--                                <select name="sex" th:with="type=${@dict.getType('sys_user_sex')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
                            <li>
                                <label>部门名称：</label>
                                <input type="text" name="dept"/>
                            </li>
                            <li>
                                <label>是否实习：</label>
                                <input type="text" name="isTrainee"/>
                            </li>
                            <li>
                                <label>员工岗位：</label>
                                <input type="text" name="post"/>
                            </li>
<!--                            <li>-->
<!--                                <label>员工手机：</label>-->
<!--                                <input type="text" name="phone"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addandsalary()" shiro:hasPermission="system:employee:add">
                    <i class="fa fa-plus"></i> 入职
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:employee:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:employee:remove">
                    <i class="fa fa-remove"></i> 批量退休
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:employee:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:employee:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:employee:remove')}]];
        var transferdeptFlag = [[${@permission.hasPermi('system:employee:transferdept')}]];
        var transferpostFlag = [[${@permission.hasPermi('system:employee:transferpost')}]];
        var uploadfilesFlag = [[${@permission.hasPermi('system:employee:uploadfiles')}]];
        var traineetoemployeeFlag = [[${@permission.hasPermi('system:employee:traineetoemployee')}]];
        var leaveFlag = [[${@permission.hasPermi('system:employee:leave')}]];
        // var downloadfilesFlag = [[${@permission.hasPermi('system:employee:downloadfiles')}]];
        // var viewfilesFlag = [[${@permission.hasPermi('system:employee:viewfiles')}]];
        var sexDatas = [[${@dict.getType('sys_user_sex')}]];
        var prefix = ctx + "system/employee";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                transferdeptUrl: prefix + "/transferdept/{id}",
                transferpostUrl: prefix + "/transferpost/{id}",
                uploadfilesUrl: prefix + "/uploadfiles/{id}",
                traineetoemployeeUrl: prefix + "/traineetoemployee",
                leaveUrl: prefix + "/leave/{id}",
                // viewfilesUrl: "{files}",
                // salaryUrl: prefix + "/salary",
                exportUrl: prefix + "/export",
                modalName: "员工",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'employeeId',
                    title: '员工编号',
                    visible: true,
                    sortable: true
                },
                {
                    field: 'employeeName',
                    title: '员工姓名'
                },
                {
                    field: 'sex',
                    title: '员工性别',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(sexDatas, value);
                    },
                    sortable: true
                },
                {
                    field: 'age',
                    title: '员工年龄',
                    sortable: true
                },
                {
                    field: 'dept',
                    title: '部门名称'
                },
                {
                    field: 'post',
                    title: '员工岗位'
                },
                {
                    field: 'phone',
                    title: '员工手机'
                },

                {
                    // field: '',
                    title: '档案',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var url = row.employeeFiles;
                        var actions = [];
                        if(url === "0"){
                            actions.push('<i><font color="red">未上传</font></i>');
                        }
                        else {
                            actions.push('<a target="_blank" href="' + url + '"><i class="fa fa-search"></i></a> ');
                            // actions.push('<a href="javascript:void(0)" onclick="$.operate.downloadfiles(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>下载</a> ');
                            actions.push('<a href="' + prefix + '/downloadfiles/?path=D:/employeefiles/upload/' + url + '"><i class="fa fa-download"></i></a> ');

                        }
                        // ' + url + '
                        // actions.push(url.isEmpty()?'<a target="_blank" href="' + url + '"><i class="fa fa-edit"></i>查看</a> ':'<i>未上传</i>')
                        return actions.join('');
                    }

                },

                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>信息</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + uploadfilesFlag + '" href="javascript:void(0)" onclick="$.operate.uploadfiles(\'' + row.employeeId + '\')"><i class="fa fa-upload"></i>档案</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + leaveFlag + '" href="javascript:void(0)" onclick="$.operate.leaveback(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>请假</a> ');
                        var more = [];
                        // more.push('<a class="btn btn-default btn-xs ' + transferdeptFlag + '" href="javascript:void(0)" onclick="$.operate.transferdept(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>部门</a> ');
                        // more.push('<a class="btn btn-default btn-xs ' + transferpostFlag + '" href="javascript:void(0)" onclick="$.operate.transferpost(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>岗位</a> ');
                        more.push("<a class='btn btn-default btn-xs " + transferdeptFlag + "' href='javascript:void(0)' onclick='transferdept(" + row.employeeId + ")'><i class='fa fa-edit'></i>部门</a> ");
                        more.push("<a class='btn btn-default btn-xs " + transferpostFlag + "' href='javascript:void(0)' onclick='transferpost(" + row.employeeId + ")'><i class='fa fa-edit'></i>岗位</a> ");
                        // more.push("<a class='btn btn-default btn-xs " + traineetoemployeeFlag + "' href='javascript:void(0)' onclick='traineetoemployee(" + row.employeeId + ", " + row.isTrainee + ")'><i class='fa fa-edit'></i>转正</a>");
                        actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>调动</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.employeeId + '\')"><i class="fa fa-remove"></i>退休</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //部门调动
        function transferdept(id) {
            table.set();
            //"system/employee/transferdept/2"
            var url = table.options.transferdeptUrl.replace("{id}", id);
            $.modal.open(table.options.modalName + "部门调动", url, 800, 200);
        }

        //岗位调动
        function transferpost(id) {
            table.set();
            var url = table.options.transferpostUrl.replace("{id}", id);
            $.modal.open(table.options.modalName + "岗位调动", url, 800, 200);
        }
    </script>
</body>
</html>